package com.efuture.vdrp.android.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class RegServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("GBK");
		response.setCharacterEncoding("gbk");
		String name = request.getParameter("name");
		String unit = request.getParameter("unit");
		String phone = request.getParameter("phone");
		String pwd = request.getParameter("pwd");
		//MySQL sql = new MySQL();
		WebApplicationContext webcontext = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());
		MySQL sql =(MySQL)webcontext.getBean("MySQL");
		sql.getConn();
		String str=sql.reg(name, unit, phone, pwd);
		sql.close();

		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		out.println(str);
		out.flush();
		out.close();
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doGet(request, response);
	}

}
